package erfgame.core.world.terrain;

import java.io.Serializable;

public class TerrainUpdate implements Serializable {
	
	private static final long serialVersionUID = 0;
	
	/**
	 * The terrain should be overwritten with the terrain type only if it is air, otherwise
	 * it is left as is. Can be used to simulate leave existing by using air as the value to overwrite with
	 */
	public static final short FLAG_OVERWRITE_IF_AIR = 0x0000;
	
	/**
	 * Indicates that the terrain type should always be written, regardless of what it overwrites
	 */
	public static final short FLAG_FORCE_OVERWRITE  = 0x0100;
	
	private short[][][] terrain;
	private int width;
	private int height;
	private int depth;
	private int[][][] summary;
	
	public TerrainUpdate( short[][][] terrain, int width, int height, int depth ) {
		this( 
				terrain, 
				width, 
				height, 
				depth, 
				TerrainUtils.deriveTerrainSummary(terrain, new int[width][height][], width, height)
		);
	}
	
	public TerrainUpdate( short[][][] terrain, int width, int height, int depth, int[][][] summary) {
		this.terrain = terrain;
		this.width = width;
		this.height = height;
		this.depth = depth;
		this.summary = summary;
	}
	
	public short[][][] getTerrain() {
		return this.terrain;
	}
	
	public int getWidth() {
		return this.width;
	}
	
	public int getHeight() {
		return height;
	}
	
	public int getDepth() {
		return this.depth;
	}
	
	public int[][][] getSummary() {
		return this.summary;
	}
}
